package com.eye.catcher.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eye.catcher.entity.TSysDaModule;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.eye.catcher.system.module.param.ModuleDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author huzhiwei
 * @since 2022-02-08
 */
@Mapper
public interface TSysDaModuleMapper extends BaseMapper<TSysDaModule> {

    String querySql = " select m.*," +
            " (select count(1) from t_sys_da_module m1 where m1.PARENT_ID = m.id ) leafCount " +
            " from t_sys_da_module m ";

    String wrapperSql = " select * from (" + querySql + ") as q ${ew.customSqlSegment}";

    @Select(wrapperSql)
    public abstract IPage<TSysDaModule> page(Page<TSysDaModule> page,@Param("ew")  QueryWrapper<TSysDaModule> wrapper);

    public abstract List<ModuleDto> getModule(String userId);

    public abstract List<ModuleDto> getAllModuleList();

}
